package com.ih.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ih.pojo.Salary;
import com.ih.pojo.WaterDetails;
import com.ih.pojo.Worker;
import com.ih.service.WaterDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/stat")
@Slf4j
public class WaterDetailsCotroller {
    @Autowired
    private WaterDetailsService waterDetailsService;

    /**
     * 模糊查询带分页
     * @param pageNum
     * @param pageSize
     * @param waterDetails
     * @param model
     * @return
     */
    @RequestMapping("/statWaterDetails")
    public String IsNullWorker(@RequestParam(required = false,defaultValue = "1",value = "pageNum") Integer pageNum,
                               @RequestParam(required = false,defaultValue = "10",value = "pageSize") Integer pageSize,
                               WaterDetails waterDetails, Model model) {
        if (pageNum==null||pageNum<=0 || pageNum.equals("")){
            pageNum=1;
        }
        if (pageSize==null||pageSize<=0 || pageSize.equals("")){
            pageSize=10;
        }
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<WaterDetails> pageInfo = waterDetailsService.queryWaterDetails(waterDetails,pageNum,pageSize);
        model.addAttribute("pageInfo", pageInfo);
        return "waterDetailsList";
    }
}
